<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    toString()  // 将其他类型转化为字符串
    var num = 10;
    var num = true;
    var num = "hellow";
    var num = [1,2,3];// "1.2,3"
    var num = {a :1 , b:2};//"[object Object]"
    var str = num.toString();
    console.log(str);

    // toString(n)  //十进制 转 n进制  
    var num = 15;
    var str_2 = num.toString(2); 
    var str_4 = num.toString(4); 
    var str_8 = num.toString(8); 
    console.log(str_2); // '1111'
    console.log(str_4); // '33'
    console.log(str_8); // '17'

    // parseInt(str,n)   //n进制(默认10)  转  十进制     (把n进制的数str  转化为十进制)

    var num_2 = parseInt(str_2,2);
    console.log(num_2);
    var num_4 = parseInt(str_4,4);
    console.log(num_4);



    var a = 3;
    var b = 5;

    // padStart(length,char) 头部补全   ppend
    // length 字符串的长度
    // char   长度不够时 用于补全的字符
    console.log(a.toString(2).padStart(8,"0")); 
    console.log(b.toString(2).padStart(8,"0"));
    console.log(a&b);
</script>
</html>